package com.example.demo.SinglePattern;

/**
 * @author gyq
 * @description 双重检查锁 单例模式 懒汉模式
 * @datetime 2019/2/23 19:40
 */
public class DoubleCheckedSingleLazyPattern {
    private static DoubleCheckedSingleLazyPattern doubleCheckedSingleLazyPatterns;

    private DoubleCheckedSingleLazyPattern() {
    }

    public static DoubleCheckedSingleLazyPattern getInstance() {
        if (null == doubleCheckedSingleLazyPatterns) {
            synchronized (DoubleCheckedSingleLazyPattern.class) {
                if (null == doubleCheckedSingleLazyPatterns) {
                    doubleCheckedSingleLazyPatterns = new DoubleCheckedSingleLazyPattern();
                }
            }
        }
        return doubleCheckedSingleLazyPatterns;
    }
}
